package com.thirdnf.wigets;

import com.jformdesigner.annotations.BeanInfo;
import com.jformdesigner.annotations.DesignCreate;

import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.net.URL;


@BeanInfo(description = "Icon Button", icon = "/com/thirdnf/widgets/noIcon.png")
public class IconButton extends JButton
{
    private static final Border OverBorder = new CompoundBorder(LineBorder.createBlackLineBorder(), new EmptyBorder(2, 2, 2, 2));
    private static final Border OutBorder = new EmptyBorder(3,3,3,3);

    @DesignCreate
    private static IconButton designCreate() {
        IconButton iconButton = new IconButton();
        URL url = iconButton.getClass().getResource("/com/thirdnf/widgets/noIcon.png");
        if (url != null) {
            iconButton.setIcon(new ImageIcon(url));
        }
        return iconButton;
    }


    public IconButton() {
        setText("");

        setBorder(OutBorder);

        addMouseListener(new MouseListener() {
            @Override
            public void mouseClicked(MouseEvent e) {
                //To change body of implemented methods use File | Settings | File Templates.
            }

            @Override
            public void mousePressed(MouseEvent e) {
                //To change body of implemented methods use File | Settings | File Templates.
            }

            @Override
            public void mouseReleased(MouseEvent e) {
                //To change body of implemented methods use File | Settings | File Templates.
            }

            @Override
            public void mouseEntered(MouseEvent e) {
                setBorder(OverBorder);
            }

            @Override
            public void mouseExited(MouseEvent e) {
                setBorder(OutBorder);
            }
        });
    }


    @Override
    public String getText() {
        return "";
    }
}
